package pushtest.mobike.com.mtpush

import android.app.Application


fun Application.currentProcessName(): String? {
  val pid = android.os.Process.myPid()
  var res: String? = null
  for (appProcess in this.activityManager.runningAppProcesses) {
    if (appProcess.pid == pid) {
      res = appProcess.processName
    }
  }
  return res
}
val Application.activityManager
  get() = getSystemService(
    android.content.Context.ACTIVITY_SERVICE
  ) as android.app.ActivityManager

fun Application.isMainProcess(): Boolean = this.packageName == currentProcessName()




